# dust daemon Makefile
# 
# @author krdlab
# @refer http://www.unixuser.org/~euske/doc/makefile/
# @refer http://www.02.246.ne.jp/~torutk/cxx/make/gnumake.html
# @refer http://www-or.amp.i.kyoto-u.ac.jp/algo-eng/db/makefile.html

TARGET= dustd
SRCS  = dustd.cc cgi.cc http.cc http_request.cc connection.cc mime_type.cc utils.cc logger.cc
OBJS  = $(SRCS:.cc=.o)

# uncomment when debugging
#DEBUG	= -ggdb -pg # -lefence

# linker (*.o)
LD      = g++
LDFLAGS = -g $(DEBUG)           # linker options
LDLIBS  = -lm -lpthread         # libraries

# C++ (*.cc)
CXX	    = g++
CXXFLAGS= -g -O2 -Wall $(DEBUG) # compile options
CPPFLAGS=                       # preprocessor options
INCLUDES= -I./                  # include files/directories

# command
RM      = rm
RMFLAGS = -rf

# rules
.PHONY: all
all: $(TARGET)

$(TARGET): $(OBJS)
	$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)

.cc.o:
	$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) -c $<  # '-c': compile only

.PHONY: clean
clean:
	$(RM) $(RMFLAGS) $(TARGET) $(OBJS)
